<!DOCTYPE html>
<!--suppress ALL -->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数</title>
</head>
<body>
<script type="text/javascript">
    /*function print(msg) {
        document.writeln(msg + "<br>")
        return "已经处理了消息"
    }

    let msg = print("我来组成头部")
    document.writeln(msg)*/
    /* let printMsg = function (msg) {
         document.writeln(msg + "<br>")
         return "Msg have been processed"
     }
     let msgs = printMsg("Are you ready?")
     document.writeln(msgs)
    var printMessage = new Function("message", "document.writeln(message+'<br>');");
    printMessage("hello Function");*/
    //    var myDate = new Date()
    //    document.writeln(myDate.getFullYear() + "/" + (myDate.getMonth() + 1) + "/" + myDate.getDate());
    function display(arg) {
        var output = ""
        if (typeof arg.name == "string") {
            output += "Name: " + arg.name + "\n";
        }
        if (typeof arg.age == "number") {
            output += "Age: " + arg.age + "\n";
        }
        alert(output);
    }

    display({
        name: "Nicholas",
        age: 29
    });
    display({
        name: "Greg"
    });
</script>
</body>
</html>